import request from '@/utils/request'

// 查询streaming任务配置列表
export function listJobConfig(query) {
  return request({
    url: '/streaming/JobConfig/list',
    method: 'get',
    params: query
  })
}

// 查询streaming任务配置详细
export function getJobConfig(id) {
  return request({
    url: '/streaming/JobConfig/' + id,
    method: 'get'
  })
}

// 新增streaming任务配置
export function addJobConfig(data) {
  return request({
    url: '/streaming/JobConfig',
    method: 'post',
    data: data
  })
}

// 修改streaming任务配置
export function updateJobConfig(data) {
  return request({
    url: '/streaming/JobConfig',
    method: 'put',
    data: data
  })
}

// 删除streaming任务配置
export function delJobConfig(id) {
  return request({
    url: '/streaming/JobConfig/' + id,
    method: 'delete'
  })
}

// 导出streaming任务配置
export function exportJobConfig(query) {
  return request({
    url: '/streaming/JobConfig/export',
    method: 'get',
    params: query
  })
}


// 任务状态修改
export function changeJobStatus(userId, status) {
  const data = {
    userId,
    status
  }
  console.log(data);
  return request({
    url: 'streaming/JobConfig/changeStatus',
    method: 'post',
    data: data
  })
}

// 任务状态修改
export function openJob(id) {
  const data = {
    id
  }
  console.log(data);
  return request({
    url: 'streaming/JobConfig/open',
    method: 'post',
    data: data
  })
}

// 任务状态修改
export function closeJob(id ) {
  const data = {
   id
  }
  console.log(data);
  return request({
    url: 'streaming/JobConfig/close',
    method: 'post',
    data: data
  })
}


//开启任务
export function startJob(id) {
  const data = {
   id
  }
  console.log(data);
  return request({
    url: 'streaming/JobConfig/start',
    method: 'post',
    data: data
  })
}

// 停止任务
export function stopJob(id) {
  const data = {
   id
  }
  return request({
    url: 'streaming/JobConfig/stop',
    method: 'post',
    data: data
  })
}


// stop job with savepoint
export function savepointStop(id) {
  const data = {
   id,
   "savepointPath":""
  }
  return request({
    url: 'streaming/JobConfig/stopSavepointJob',
    method: 'post',
    data: data
  })
}

// savepoint start
export function savepointStart(jobId, savepointId) {
  const data = {
    id:jobId,
    savepointId:savepointId
  }
  return request({
    url: 'streaming/JobConfig/start',
    method: 'post',
    data: data
  })
}

